"""
安装并导包
打开excel
获取sheet页
获取最大行、最大列
获取某个单元格的值
获取某行、列的值
"""
import xlrd
import os
class readexcel():
    def __init__(self):
        self.path_name=os.path.dirname(os.path.dirname(__file__))+'/testdata/data.xls'
        self.readbook=xlrd.open_workbook(self.path_name)
        self.sheet=self.readbook.sheet_by_index(0)
        self.max_row=self.sheet.nrows
        self.max_col=self.sheet.ncols
        self.res_list=[]
        self.fir_row=self.sheet.row_values(0)

    def read(self):
        for i in range(1,self.max_row):
            row_value=self.sheet.row_values(i)
            dict1={self.fir_row[j]:row_value[j] for j in range(self.max_col)}
            self.res_list.append(dict1)
        return self.res_list
if __name__ == '__main__':
    re=readexcel()
    print(re.read())